package com.ruoyi.customerSample.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;

import com.ruoyi.customerSample.domain.SampleSendDetails;
import com.ruoyi.customerSample.service.ISampleSendDetailsService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 来样登记明细信息Controller
 * 
 * @author ruoyi
 * @date 2023-07-05
 */
@RestController
@RequestMapping("/sample/senDetails")
@Api(value="来样登记明细信息",tags = "来样登记明细信息接口")
public class SampleSendDetailsController extends BaseController
{
    @Autowired
    private ISampleSendDetailsService sampleSendDetailsService;

    /**
     * 查询来样登记明细信息列表
     */
    @GetMapping("/list")
    @ApiOperation(value="查询来样登记明细信息列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "pageNum", value = "页数", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "pageSize", value = "每页记录数", required = true, dataType = "String"),
    })
    public TableDataInfo list(SampleSendDetails sampleSendDetails)
    {
        startPage();
        List<SampleSendDetails> list = sampleSendDetailsService.selectSampleSendDetailsList(sampleSendDetails);
        return getDataTable(list);
    }

    /**
     * 导出来样登记明细信息列表
     */
    @Log(title = "来样登记明细信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SampleSendDetails sampleSendDetails)
    {
        List<SampleSendDetails> list = sampleSendDetailsService.selectSampleSendDetailsList(sampleSendDetails);
        ExcelUtil<SampleSendDetails> util = new ExcelUtil<SampleSendDetails>(SampleSendDetails.class);
        return util.exportExcel(list, "details");
    }

    /**
     * 获取来样登记明细信息详细信息
     */
    @GetMapping(value = "/{id}")
    @ApiOperation(value="获取来样登记明细信息详细信息")
    @ApiImplicitParam(paramType="query", name = "id", value = "主键", required = true, dataType = "String")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(sampleSendDetailsService.selectSampleSendDetailsById(id));
    }

    /**
     * 根据来样登记单位和日期获取明细信息
     */
    @GetMapping("/getInfoByClientDate")
    @ApiOperation(value="根据来样登记单位和日期获取明细信息")
    public AjaxResult getInfoByClientDate(@ApiParam(name="受检单位名称",value="传入字符串格式",required=true)String client, @ApiParam(name="来样日期",value="传入字符串格式",required=true)String reDate)
    {
        return AjaxResult.success(sampleSendDetailsService.selectSampleSendDetailsByClient(client, reDate));
    }

    /**
     * 新增来样登记明细信息
     */
    @Log(title = "来样登记明细信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value="新增来样登记明细信息")
    public AjaxResult add(@ApiParam(name="来样登记明细",value="传入json格式",required=true)@RequestBody SampleSendDetails sampleSendDetails)
    {
        return toAjax(sampleSendDetailsService.insertSampleSendDetails(sampleSendDetails));
    }

    /**
     * 修改来样登记明细信息
     */
    @Log(title = "来样登记明细信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value="修改来样登记明细信息")
    public AjaxResult edit(@ApiParam(name="来样登记明细",value="传入json格式",required=true)@RequestBody SampleSendDetails sampleSendDetails)
    {
        return toAjax(sampleSendDetailsService.updateSampleSendDetails(sampleSendDetails));
    }

    /**
     * 删除来样登记明细信息
     */
    @Log(title = "来样登记明细信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value="来样登记明细信息")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sampleSendDetailsService.deleteSampleSendDetailsByIds(ids));
    }
}
